package com.yuntian.mapper;

import com.github.pagehelper.Page;
import com.yuntian.Dto.CartPageQueryDto;
import com.yuntian.Vo.admin.CartVO;
import com.yuntian.entity.Cart;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CartMapper {


    List<CartVO> selectAll(Long userId);
    Page<CartVO> selectTotal(CartPageQueryDto cartPageQueryDto);

    void insertCart(Cart cart);

    void updateCart(Cart cart);


    //根据用户id和商品id查询购物车记录
    @Select("SELECT * FROM cart where user_id = #{userId} and product_id = #{productId}")
    Cart selectCartByUserIdAndProductId(Integer userId, Integer productId);
    //根据购物车id删除购物车记录
    void deleteCart(Integer cartId);
    //根据用户id清空购物车
    @Select("DELETE FROM cart where user_id = #{userId}")
    void deleteCartByUserId(Long userId);
}
